package lium.lbs.lbsim.jgchat.controller;

import android.app.Dialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.view.View;
import android.view.WindowManager;
import lium.lbs.lbsim.R;
import lium.lbs.lbsim.activity.ChangeNameHeadActivity;
import lium.lbs.lbsim.activity.ChangeSignatureActivity;
import lium.lbs.lbsim.activity.SetActivity;
import lium.lbs.lbsim.activity.WalletActivity;
import lium.lbs.lbsim.jgchat.activity.fragment.MyeFragment;
import lium.lbs.lbsim.jgchat.utils.DialogCreator;

/**
 * Created by ${chenyn} on 2017/2/21.
 */

public class MyeController implements View.OnClickListener {
    public static final String PERSONAL_PHOTO = "personal_photo";
    private MyeFragment mContext;
    private Dialog mDialog;
    private int mWidth;
    private Bitmap mBitmap;

    public MyeController(MyeFragment context, int width) {
        this.mContext = context;
        this.mWidth = width;
    }

    public void setBitmap(Bitmap bitmap) {
        this.mBitmap = bitmap;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.change_signature:
                mContext.startActivity(new Intent(mContext.getContext(), ChangeSignatureActivity.class));
                break;
            case R.id.my_wallet:
                mContext.startActivity(new Intent(mContext.getContext(), WalletActivity.class));
                break;
            case R.id.my_set:
                mContext.startActivity(new Intent(mContext.getContext(), SetActivity.class));
                break;
            case R.id.tv_loginout:
                View.OnClickListener listener = new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        switch (v.getId()) {
                            case R.id.jmui_cancel_btn:
                                mDialog.cancel();
                                break;
                            case R.id.jmui_commit_btn:
                                mContext.Logout();
                                mContext.cancelNotification();
                                mContext.getActivity().finish();
                                mDialog.cancel();
                                break;
                        }
                    }
                };
                mDialog = DialogCreator.createLogoutDialog(mContext.getActivity(), listener);
                mDialog.getWindow().setLayout((int) (0.8 * mWidth), WindowManager.LayoutParams.WRAP_CONTENT);
                mDialog.show();
                break;
            case R.id.headImage:
                mContext.startActivity(new Intent(mContext.getContext(), ChangeNameHeadActivity.class));
                break;


        }
    }
}
